import React from 'react'
import { connect } from 'dva'
import { Modal, Input, Button } from 'antd'

const { TextArea } = Input

@connect(({ staffPersonal }) => ({
  staffPersonal
}))
class XModel2 extends React.PureComponent {

  state = {
    task_remark: ''
  }

  onHandleSubmit = (e) => {
    e.preventDefault()

    const { onMarketSubmit } = this.props
    const { task_remark } = this.state
    onMarketSubmit(task_remark)
  }

  handleCancel = e => {
    e.preventDefault()

    const { dispatch } = this.props
    dispatch({
      type: 'staffPersonal/save',
      payload: {
        visible: false
      }
    })
  }

  onChange = e => {
    e.preventDefault()

    const { value } = e.target
    this.setState(state => ({
      ...state,
      task_remark: value
    }))
  }

  render() {
    const { staffPersonal } = this.props
    // eslint-disable-next-line
    const { visible, remark } = staffPersonal
    console.log(remark, 123)

    return (
      <Modal
        visible={visible}
        closable={false}
        footer={null}
        width={500}
        onCancel={this.handleCancel}
        destroyOnClose="true"
      >
        <TextArea placeholder="请填写备注"  defaultValue={remark} autosize={{ minRows: 6 }} onChange={this.onChange} />
        <section style={{marginTop: 16, textAlign: 'center'}}>
          <Button type='primary' size='large' block onClick={this.onHandleSubmit}>提交</Button>
        </section>
      </Modal>
    )
  }
}

export default XModel2